type A = {
    username:string;
    age:number
}

//映射类型只能用别名实现，不能用接口
type B<T> = {
    [P in keyof T] :T[P]
}
//与A一样
type C = B<A>

type B1<T> = {
    //都只读
   readonly [P in keyof T] :T[P]
}

//内置Partial<T> , Readonly<T> , Required<T> , Pick<T,K> , Record<K,T> , Exclude<T,U> , Omit<T,K>, Extends<T,U>

type A1 = {
    username:string
    age:number
    sex:boolean,
    height?:number
}

//A1的所有属性都变成只读
type T = Readonly<A1>

//A1的所有属性都变成可选
type D = Partial<A1>

//筛选出A1的username
type E = Pick<A1 , 'username'|'age'>

//属性都变成string
type F = Record<keyof A1,string>

//属性必须都有
type G = Required<A1>

//只留username
type H = Pick<A1, 'username'>

//排除username
type I = Omit<A1, 'username'>
